<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" href="/account/css/pintuer.css">
<link rel="stylesheet" href="/account/css/admin.css">
	<link rel="stylesheet" href="/account/layui/layui/css/layui.css">
	<script type="text/javascript" src="/account/layui/layui/layui.js"></script>
<script type="text/javascript" src="/account/js/jquery-3.5.1.min.js"></script>
<script type="text/javascript" src="/account/js/vue.js"></script>

</head>
<body>
	<div class="panel admin-panel" id="app">
		<div class="panel-head" id="add">
			<strong><span class="icon-pencil-square-o"></span>新增入账表</strong>
		</div>

		<div class="body-content">
			<form  id="form" class="form-x" >
				<div class="form-group">
					<div class="label">
						<label>流水单号：</label>
					</div>
					<div class="field">
						<input type="text" class="input w50" value="" name="accountSerialNum" id="accountSerialNum"/>
					</div>
				</div>
				
					<div class="form-group">
					<div class="label">
						<label>总金额：</label>
					</div>
					<div class="field">
						<input type="text" class="input w50" value="" name="accountTotal"  id="accountTotal"/>

					</div>
				</div>
				<div class="form-group">
					<div class="label">
						<label>项目id：</label>
					</div>
					<div class="field">
						<input type="text" class="input w50" value="" name="accountProjectId"  id="accountProjectId"/>
						
					</div>
				</div>
				<div class="form-group">
					<div class="label">
						<label>工序号：</label>
					</div>
						<select  class="input" id="accountOperationNum"
								 style="width: 200px; line-height: 17px;">
							<option value=-1 >请选择工序号</option>
							<option value=0 >定金</option>
							<option value=1 >施工一阶段</option>
							<option value=2 >施工二阶段</option>
							<option value=3 >施工三阶段</option>
							<option value=4>施工四阶段</option>
							<option value=5>施工五阶段</option>

						</select>
					</div>

				<div class="form-group">
					<div class="label">
						<label>支付状态：</label>
					</div>
					<select  class="input" id="accountRemark"
							 style="width: 200px; line-height: 17px;">
						<option value=0 >请选择支付状态</option>
						<option value=1>已支付</option>
						<option value=2 >未支付</option>
					</select>
				</div>
				<div class="form-group">
					<div class="label">
						<label>凭证图片：</label>
					</div>
					<input type="button" value="添加" onclick="addOne()">

					<div id="addDiv"></div>
				</div>

				<div class="form-group">
					<div class="label">
						<label></label>
					</div>
					<div class="field">
						<button class="button bg-main icon-check-square-o" type="button" onclick="insertAccount()">
							提交</button>
<!--						<button class="button bg-main icon-check-square-o" type="button" onclick="insertPic()">-->
<!--							图片</button>-->
					</div>
				</div>

			</form>
		</div>
	</div>
</body>

<script type="text/javascript">
	var html="<div> <br><input type='file'  multiple='multiple'  name='myfile' id='img' />";
	function addOne() {
		// document.getElementById("addDiv").innerHTML += "<div> <input type='file' name='myfile' id='img' />"
		$("#addDiv").append(html);
	}

	// var _this;
	// var app=new Vue({
	// 	el:"#app",
	// 	data:{
	// 		operationNum:null,
	//
	// 		//定义查询条件对象
	//
	// 	},
	// 	created:function(){
	// 		_this=this;
	// 		this.selectByExample();
	// 	},
	// 	methods:{
	// 		//查询部门信息
	// 		selectByExample:function(){
	// 			_this=this;
	// 			$.ajax({
	// 				url:"/farmergoods/query",
	// 				type:"get",
	// 				dataType:"json",
	// 				success:function(data){
	// 					_this.category=data.list;
	// 				}
	// 			})
	// 		}
	// 	}
	// });

	// function insertAccount(){
	//
	// 	$.ajax({
	// 		url:"/account/insert",
	// 		type:"post",
	// 		data:{
	// 			accountSerialNum:$("#accountSerialNum").val(),
	// 			accountTotal:$("#accountTotal").val(),
	// 			accountProjectId:$("#accountProjectId").val(),
	// 			accountOperationNum:$("#accountOperationNum").val(),
	// 			accountRemark:$("#accountRemark").val()
	// 		},
	// 		dataType:"json",
	// 		success:function(data){
	// 			alert("新增成功");
	// 			location.href="account.html";
	// 		},
	// 		error:function(error){
	// 			alert("新增失败");
	// 		}
	// 	})
	// }
	function insertPic(){
		var formData = new FormData();
		var list=document.getElementsByName("myfile");

		for(let i=0;i<list.length;i++){
			if((list[i].files[0]!=null)){
				formData.append("img",list[i].files[0]);
			}

		}

		$.ajax({
			url:"/account/upload/uploadImg",
			type:"post",
			data:formData,
			dataType:"json",
			processData:false,
			contentType:false,
			success:function(data){
				alert("新增成功");
			},
			error:function(error){
				alert("新增失败");
			}
		})
	}
	function insertAccount(){
		var formData = new FormData();
		var list=document.getElementsByName("myfile");
		for(let i=0;i<list.length;i++){
			if((list[i].files[0]!=null)){
				formData.append("img",list[i].files[0]);
			}
		}
		formData.append("accountSerialNum",$("#accountSerialNum").val());
		formData.append("accountTotal",$("#accountTotal").val());
		formData.append("accountProjectId",$("#accountProjectId").val());
		formData.append("accountOperationNum",$("#accountOperationNum").val());
		formData.append("accountRemark",$("#accountRemark").val());
		$.ajax({
			url:"/account/account/insert",
			type:"post",
			data:formData,
			dataType:"json",
			processData:false,
			contentType:false,
			success:function(data){
				alert("新增成功");
				location.href="/account/account.html";
			},
			error:function(error){
				alert("新增失败");
			}
		})
	}
</script>
</html>